<template>
  <div class="dashboard-container">
    <div class="app-container">
      <el-card>
        <el-tabs>
          <el-tab-pane label="登录账户设置">

            <!-- 放置表单 -->
            <el-form label-width="120px" :model="formData" style="margin-left: 120px; margin-top:30px">
              <el-form-item label="姓名:">
                <el-input v-model="formData.username" style="width:300px" />
              </el-form-item>
              <el-form-item label="密码:">
                <el-input
                  v-model="formData.passworld"
                  style="width:300px"
                  type="password"
                />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="putUser">更新</el-button>
              </el-form-item>
            </el-form>
          </el-tab-pane>
          <el-tab-pane label="个人详情">
            <component :is="page1" />
          </el-tab-pane>
          <el-tab-pane label="岗位信息">
            <component :is="page2" />
          </el-tab-pane>
        </el-tabs>
      </el-card>
    </div>
  </div>
</template>

<script>
import userInfo from '@/views/employees/component/userInfo.vue'
import jobInfo from '@/views/employees/component/jobInfo.vue'
import { putStaff, staffInfo } from '@/api/staff'
export default {
  components: {
    userInfo,
    jobInfo
  },
  data() {
    return {
      page1: 'userInfo',
      page2: 'jobInfo',
      formData: {},
      id: this.$route.params.id
    }
  },
  async created() {
    const res = await staffInfo(this.id)
    this.formData = {
      ...res, passworld: ''
    }
  },
  methods: {
    async putUser() {
      await putStaff(this.formData)
      this.$message.success('修改密码成功')
      const res = await staffInfo(this.id)
      this.formData = {
        ...res, passworld: ''
      }
    }
  }
}
</script>

<style>

</style>
